<template>
    <div class="tabNav">
        <div class="item2" @click="openClassModal">
            <span>{{classItem.gradeName}}{{classItem.className}}</span>
            <span class="iconfont" style="font-size:0.18rem">&#xe611;</span>
        </div>
        <div class="item" @click="openSort">
            {{sortName}}
            <span class="iconfont" style="font-size:0.18rem">&#xe611;</span>
        </div>
        <div class="item" @click="openTime">
            {{timerName}}
            <span class="iconfont" style="font-size:0.18rem">&#xe611;</span>
        </div>
        <div class="item" @click="handelEwm">评价<span class="iconfont">&#xe661;</span></div>
    </div>
</template>

<script>
import { Toast } from 'vant';
export default {
    name:'tabNav',
    props:['timerName','sortName'],
    computed:{
        classItem(){
            return this.$store.state.studentAppraise.classItem;
        },
        schoolId(){
            return this.$store.state.user.schoolId;
        }
    },
    methods:{
        openClassModal(){
            this.$emit('openClassModal')
        },
        openSort(){
            this.$emit('openSort')
        },
        openTime(){
            this.$emit('openTime')
        },
        handelEwm(){
            var _this = this;
            wx.scanQRCode({
                needResult: 1,  
                scanType: ["qrCode", "barCode"],  
                async success(res) {
                    var id = res.resultStr;
                    _this.$store.dispatch('studentAppraise/GetStudentInfo',id).then(res=>{
                        var data = res.data;
                        if(_this.schoolId != data.schoolId){
                            Toast.fail('非该校学生');
                            return
                        }
                        var studentsInfo = {
                            id:data.id,
                            name:data.name,
                            portraitImgUrl:data.portraitImgUrl
                        }
                        var classItem = {
                            gradeId:data.gradeId,
                            classId:data.classId,
                            gradeName:data.gradeName,
                            className:data.className
                        }
                        _this.$store.commit('studentAppraise/setStudentsInfo',studentsInfo)
                        _this.$store.commit('studentAppraise/setClassItem',classItem)
                        _this.$router.push('/studentAppraise/studentRecord')

                    }).catch(err =>{
                        Toast.fail('识别该学生不存在');
                    })
                }
            })
        }
    }
}
</script>

<style lang="less" scoped>

 @import url('../../../../assets/css/iconfont.css');
.tabNav{
    box-sizing: border-box;
    line-height: 0.8rem;
    background-color:#fff;
    display: flex;
    border-bottom: 0.01rem solid #f5f5f5;
    .item2{
        width: 2.4rem;
        text-align: center;
        position: relative;
        box-sizing: border-box;
        overflow:hidden;
        .iconfont{
            font-size:0.24rem;
            padding-left: 0.05rem;
        }
    }
    .item2:after{
        content: '';
        width:0.01rem;
        height: 0.32rem;
        background-color:#ddd;
        position: absolute;
        right:0;
        top:0.21rem;
    }
    .item{
        flex:1;
        text-align: center;
        position: relative;
        box-sizing: border-box;
        overflow:hidden;
        .iconfont{
            font-size:0.24rem;
            padding-left: 0.05rem;
        }
    }
    .item:after{
        content: '';
        width:0.01rem;
        height: 0.32rem;
        background-color:#ddd;
        position: absolute;
        right:0;
        top:0.21rem;
    }
    .item:last-child:after{
        width:0;
        height:0;
    }
}
</style>

